﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartWMS.Common.Extensions;
using SmartWMS.Common.ResponseOutput;
using SmartWMS.Domain.BasicsDatum;
using SmartWMS.EntityFramework;
using SmartWMS.Server.BasicsDatumServer.SupplierManagement;

namespace SmartWMS.API.Controllers.BasicsDatumMange
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SupplierManagementController : ControllerBase
    {
        private readonly ISupplierManagement _supplierManagement;
        public SupplierManagementController(ISupplierManagement supplierManagement)
        {
            _supplierManagement = supplierManagement;
        }

        /// <summary>
        /// 供应商管理列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public IActionResult GetSupplierManagementDtoDtoAsyne(SupplierFyDto supplierFyDto)
        {
            var list= _supplierManagement.GetSupplierManagementDtoDtoAsyne(supplierFyDto);

            return Ok(new
            {
                supplierFyDto.totalCount,
                supplierFyDto.pageCount,
                list
            });
        }


        /// <summary>
        /// 供应商管理删除
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> DeleteSupplierManagementDtoAsyne(SupplierManagementDto dto)
        {
            return _supplierManagement.DeleteSupplierManagementDtoAsyne(dto);
        }


        /// <summary>
        /// 供应商管理添加
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> SupplierManagementDtoAddSave(SupplierManagementDto dto)
        {
            //添加
            return _supplierManagement.SupplierManagementDtoAddSave(dto);
        }


        /// <summary>
        /// 供应商管理反填
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Response<SupplierManagementDto> GetSupplierManagementById(SupplierManagementDto dto)
        {
            //反填
            return _supplierManagement.GetSupplierManagementById(dto);
        }

        /// <summary>
        /// 供应商管理修改
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<Response<bool>> SupplierManagementUpdate(SupplierManagementDto dto)
        {
            return await _supplierManagement.SupplierManagementUpdate(dto);
        }

        /// <summary>
        /// 批量删除供应商
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<Response<bool>> DeletesSupplierManagementIsDisable(SupplierManagementDto dto)
        {
            return _supplierManagement.DeletesSupplierManagementIsDisable(dto);
        }

    }
}
